<template>
  <div class="usercontainer">
    <!-- 显示用户或群组 -->
    <div class="peopleList">
      <div class="people"
           v-for="msg in latestMsg"
           :key="msg.m_ID"
           @click="reviseUser(msg)">

        <el-avatar :src="msg.m_Icon"
                   size="medium"
                   class="other_avatar"></el-avatar>

        <div class="wrap">
          <div class="top">
            <div class="username">{{msg.m_NickName}}</div>
          </div>
          <div class="message">发来了些消息...</div>
        </div>

      </div>

    </div>
  </div>
</template>

<script>
export default {
  name: 'LatestMsg',
  props: ['latestMsg'],
  data () {
    return {
      userData: {
        avatar: '',
        loginID: '',
        nickName: ''
      }
    }
  },
  methods: {
    reviseUser (msg) {
      var id = msg.m_FromUserID === window.sessionStorage.getItem('selfInfo') ? msg.m_ToUserID : msg.m_FromUserID
      this.userData.avatar = msg.m_Icon
      this.userData.loginID = id
      this.userData.nickName = msg.m_NickName
      this.$emit('reviseToUser', this.userData)
    }
  }
}
</script>

<style lang="less" scoped>
.usercontainer {
  position: relative;
  width: 100%;
  height: 530px;
}
.peopleList {
  width: 100%;
  height: 100%;
  overflow: auto;
  position: absolute;
  top: 0;
  padding-left: 10px;
  .people {
    width: 100%;
    height: 50px;
    margin-bottom: 2px;
    border-bottom: 1px solid #9195a323;
    display: flex;
    justify-content: space-between;
    position: relative;

    // 徽章
    .badge {
      position: absolute;
      left: 10px;
      top: 0;
      width: 40px;
      height: 50%;
    }
    .other_avatar {
      margin-top: 5px;
    }

    .wrap {
      font-size: 13px;
      font-family: "黑体";
      margin-top: 10px;
      width: 80%;
      margin-left: 10px;
      .top {
        display: flex;
        justify-content: space-between;
        .username {
          font-weight: bold;
        }

        .date {
          color: rgba(153, 153, 153, 0.753);
        }
      }
      .message {
        float: left;
        margin-top: 5px;
        font-size: 10px;
        color: rgba(153, 153, 153, 0.753);
      }
    }
  }
}

.people:hover {
  background-color: rgba(131, 125, 125, 0.048);
}

// 左边选中边框显示
.leftborder {
  border-left: 4px solid #5bacec;
  border-radius: 2px 0 0 2px;
}
</style>
